package SolveQuestions;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Stack;

public class l150 {
    public static void main(String[] args) {
        Scanner input =new Scanner(System.in);
        String[] str = input.nextLine().split(" ");
        l150 temp = new l150();
        Solution a = temp.new Solution();
        System.out.printf("%d\n",a.evalRPN(str));;

    }
    class Solution{
        public int evalRPN(String[] tokens) {
            Stack<Integer> record = new Stack<>();
            int result = 0;
            HashSet<String> symbol = new HashSet<>();
            symbol.add("+");
            symbol.add("-");
            symbol.add("*");
            symbol.add("/");
            if(tokens.length == 1) return Integer.valueOf(tokens[0]);
            for(String val: tokens){
                if(symbol.contains(val)){
                    int temp2 = record.pop();
                    int temp1 = record.pop();
                    result = cal(temp1, temp2, val);
                    record.push(result);
                }else{
                    record.push(Integer.valueOf(val));
                }
            }
            return result;
        }

        public int cal(int x, int y, String Symbol){
            if(Symbol.equals("+")) return x + y;
            if(Symbol.equals("-")) return x - y;
            if(Symbol.equals("*")) return x * y;
            if(Symbol.equals("/")) return x / y;
            return 0;
        }
    }


}

